<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-06-28 15:19:56
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" 
-->
<template>
  <el-container style="height: 100%">
    <el-main style="height: 100%">
      <sc-VxeTable
        ref="xGrid1"
        :gridEvts="gridEvents"
        :tablecode="'basedata_financematerial'"
        :url="this.$API.basedata.financeMaterial.list"
      >
        >
      </sc-VxeTable>
    </el-main>
    <save-dialog
      v-if="dialog.save"
      ref="saveDialog"
      @success="handleSuccess"
      @closed="dialog.save = false"
    >
    </save-dialog>
  </el-container>
</template>
<script>
import SaveDialog from "./save";
export default {
  components: {
    SaveDialog,
  },
  name: "basedata_financematerial",
  data() {
    return {
      dialog: {
        save: false,
      },
      gridEvents: {
        cellDblclick: ({ row }) => {
          this.edit(row);
        },
        add: () => {
          this.add();
        },
        edit: ({ button }) => {
          this.edit(button.selectRecords[0]);
        },
        del: () => {
          this.del();
        },
      },
    };
  },
  methods: {
    add: function () {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open();
      });
    },
    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
    edit(selected) {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open("edit").setData(selected);
      });
    },
  },
};
</script>
